package tongcheng.com.tongcheng.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yanzhenjie.nohttp.RequestMethod;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import tongcheng.com.tongcheng.ConStans;
import tongcheng.com.tongcheng.R;
import tongcheng.com.tongcheng.adapter.QiangDanPeopleDetialAdapter;
import tongcheng.com.tongcheng.adapter.ThreeImageAdapter;
import tongcheng.com.tongcheng.bean.OrderDetialBean;
import tongcheng.com.tongcheng.bean.QiangDanPeopleBean;
import tongcheng.com.tongcheng.bean.StatusBean;
import tongcheng.com.tongcheng.network.CallServer;
import tongcheng.com.tongcheng.network.MyRequest;
import tongcheng.com.tongcheng.network.OnCallBack;
import tongcheng.com.tongcheng.ui.yemian.mapui.DaoHangActivity;
import tongcheng.com.tongcheng.ui.yemian.shenfen.activity.BaoZhenJinActivity;
import tongcheng.com.tongcheng.utils.GlideImageLoader;
import tongcheng.com.tongcheng.utils.GsonUtil;
import tongcheng.com.tongcheng.utils.Setting;
import tongcheng.com.tongcheng.utils.ShowToast;
import tongcheng.com.tongcheng.widght.DismissDialog;
import tongcheng.com.tongcheng.widght.MessageDialog;
import tongcheng.com.tongcheng.widght.MyBanner;

public class AllOrderDetialActivity extends BaseActivity {

    @Bind(R.id.back)
    ImageView mBack;
    @Bind(R.id.back_text)
    TextView mBackText;
    @Bind(R.id.title)
    TextView mTitle;
    @Bind(R.id.title_bar)
    RelativeLayout mBg;
    @Bind(R.id.allorderdetial_banner)
    MyBanner mAllorderdetialBanner;
    @Bind(R.id.allorderdetial_left)
    Button mAllorderdetialLeft;
    @Bind(R.id.allorderdetial_right)
    Button mAllorderdetialRight;
    @Bind(R.id.detial_cardno)
    TextView mDetialCardno;
    @Bind(R.id.detial_price)
    TextView mDetialPrice;
    @Bind(R.id.detial_dianpu_name)
    TextView mDetialDianpuName;
    @Bind(R.id.detial_dianpu_phone)
    TextView mDetialDianpuPhone;
    @Bind(R.id.detial_dianpu_area)
    TextView mDetialDianpuArea;
    @Bind(R.id.detial_shigong_leixing)
    TextView mDetialShigongLeixing;
    @Bind(R.id.detial_name)
    TextView mDetialName;
    @Bind(R.id.detial_phone)
    TextView mDetialPhone;
    @Bind(R.id.detial_starttime)
    TextView mDetialStarttime;
    @Bind(R.id.detial_endtime)
    TextView mDetialEndtime;
    @Bind(R.id.detial_shigong_renshu)
    TextView mDetialShigongRenshu;
    @Bind(R.id.detial_install_info)
    TextView mDetialInstallInfo;
    @Bind(R.id.wancheng_rc)
    RecyclerView mWanchengRc;
    @Bind(R.id.wancheng_all)
    LinearLayout mWanchengAll;
    @Bind(R.id.allbutton)
    LinearLayout mAllButton;
    @Bind(R.id.wancheng_top_left)
    TextView mWanchengTopLeft;
    @Bind(R.id.wancheng_top_right)
    TextView mWanchengTopRight;
    @Bind(R.id.wancheng_top_all)
    LinearLayout mWanchengTopAll;
    @Bind(R.id.top_line)
    View mTopLine;
    @Bind(R.id.wancheng_all_left1)
    TextView mWanchengAllLeft1;
    @Bind(R.id.wancheng_all_right1)
    TextView mWanchengAllRight1;
    @Bind(R.id.wancheng_all_left2)
    TextView mWanchengAllLeft2;
    @Bind(R.id.wancheng_all_right2)
    TextView mWanchengAllRight2;
    private int mStatus;
    private int mOrder_type;
    private int mId;
    private OrderDetialBean.DataBean mData;
    private ThreeImageAdapter mThreeImageAdapter;
    private MessageDialog mMessageDialog;
    private DismissDialog mDismissDialog;
    public String[] split = new String[]{};
    private QiangDanPeopleDetialAdapter mQiangDanPeopleDetialAdapter;
    public List<QiangDanPeopleBean.DataBean> datas = new ArrayList<>();
    private boolean aBoolean = true;
    public static AllOrderDetialActivity xiangInstance;

    @Override
    public Integer initResid() {
        return R.layout.activity_all_order_detial;
    }

    @Override
    public void initCreate(Bundle savedInstanceState) {
        xiangInstance = this;
        mMessageDialog = new MessageDialog(this);
        mMessageDialog.setMessage("请移至个人中心查看订单进度")
                .setTitle("提交成功!")
                .setOkClick(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        mMessageDialog.dismiss();
                        finish();

                    }
                });


        mDismissDialog = new DismissDialog(this);

        settitlebar(mBg);
        if (getTintManager() != null) {
            getTintManager().setNavigationBarTintResource(R.color.title_bar);
        }

        //TODO 下面2个按钮的各种判断事件
        mTitle.setText("订单详情");
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mWanchengRc.setLayoutManager(linearLayoutManager);
        mThreeImageAdapter = new ThreeImageAdapter(this, split);
        mWanchengRc.setAdapter(mThreeImageAdapter);

        //初始化订单数据
        initOrderData();

        //验证用户是否有资格抢单
        yanZheng();
    }

    int is_pledge = 0;
    String text = "";
    //验证是否交过押金
    private void yanZheng() {
        MyRequest request = new MyRequest(ConStans.ShiFouJiaoGuoYaJinUrl, RequestMethod.GET);
        request.add("userid",Setting.getId());
        CallServer.getInstance().addGet(3, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                Log.e("验证",json);
                try {
                    JSONObject object = new JSONObject(json);
                    if(object.getInt("status") == 1){
                        text = object.getString("msg");
                        JSONObject object1 = object.getJSONObject("data");
                        is_pledge = object1.getInt("is_pledge");

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, request);
    }

    private void initOrderData() {
        mId = getIntent().getIntExtra("id", -1);
        mOrder_type = getIntent().getIntExtra("order_type", -1);
        mStatus = getIntent().getIntExtra("status", -1);
        aBoolean = getIntent().getBooleanExtra("boole", true);
        Log.e("login_id", mId + "");
        Log.e("login_type", mOrder_type + "");
        Log.e("login_status", mStatus + "");
        MyRequest request = new MyRequest(ConStans.OrderDetial_Url);
        request.add("id", mId);
        /*request.add("order_type", mOrder_type);
        request.add("status", mStatus);*/
        request.add("userid", Setting.getId());
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                Log.e("订单详情",json + "");
                OrderDetialBean orderDetialBean = GsonUtil.GsonToBean(json, OrderDetialBean.class);
                if (orderDetialBean != null) {
                    ShowToast.showToast(orderDetialBean.msg);

                    if (orderDetialBean.status == 1) {
                        if (orderDetialBean.data != null) {
                            mData = orderDetialBean.data;
                            BindData(orderDetialBean.data);

                        }
                    }
                }
            }
        });
    }

    //获取抢单方信息
    private void GetQiangDanInfo() {
        MyRequest request = new MyRequest(ConStans.QueRenPeople_Url);
        request.add("orderId", mData.id);
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                Log.e("抢单方信息",json + "");
                QiangDanPeopleBean qiangDanPeopleBean = GsonUtil.GsonToBean(json, QiangDanPeopleBean.class);
                if (qiangDanPeopleBean != null) {
                    List<QiangDanPeopleBean.DataBean> data = qiangDanPeopleBean.data;
                    if (data != null) {
                        for (int i = 0; i < data.size(); i++) {
                            QiangDanPeopleBean.DataBean dataBean = data.get(i);
                            if (dataBean.id == mData.grab_id) {//如果2个抢单用户id一样

                                mWanchengAll.setVisibility(View.VISIBLE);
                                //TODO 设置完成时间和 完成之后拍的图片
                                mTopLine.setVisibility(View.VISIBLE);
                                mWanchengTopAll.setVisibility(View.VISIBLE);
                                mWanchengTopLeft.setText("抢单方");
                                mWanchengAllLeft1.setText("公司介绍");
                                mWanchengAllLeft2.setText("相关证件");
                                mWanchengTopRight.setText(dataBean.user_name + "");
                                mWanchengAllRight1.setText(dataBean.record + "");
                                String[] splits = dataBean.documents_features.split(",");
                                Log.e("抢单方信息",splits.length + "");

                                split = splits;
                                mThreeImageAdapter.setSplit(splits);
                                mThreeImageAdapter.notifyDataSetChanged();
                            } else {
                                mWanchengAll.setVisibility(View.GONE);
                                mTopLine.setVisibility(View.GONE);
                                mWanchengTopAll.setVisibility(View.GONE);
                            }
                        }
                        mThreeImageAdapter.notifyDataSetChanged();
                    }

                }
            }
        });
    }

    private void BindData(OrderDetialBean.DataBean data) {
        mDetialCardno.setText(data.order_no);//订单编号
        mDetialPrice.setText(data.price);//订单价格
        mDetialDianpuName.setText(data.shop_name);//店铺名称
        mDetialDianpuPhone.setText(data.shop_phone);//店铺电话
        mDetialDianpuArea.setText(data.shop_address);//店铺地址
        mDetialShigongLeixing.setText(data.order_title);//施工类型
        mDetialName.setText(data.principal);//负责人


        if (Setting.getId() == data.account_id) {
            mDetialPhone.setText(data.phone);
        } else if (data.status == 0 || data.status == 3) {
            mDetialPhone.setText("***********");
        } else {
            mDetialPhone.setText(data.phone);
        }

//        TimeUtiles.getCurrenttime(data.issue_time);
        mDetialStarttime.setText(data.expect_start_time_format+"");//发布日期
        mDetialEndtime.setText(data.expect_end_time_format + "");//结束日期
        mDetialShigongRenshu.setText(data.work_num + "人");
        mDetialInstallInfo.setText(data.scene_comment);//安装信息


        List<Integer> objects = new ArrayList<>();
        objects.add(R.mipmap.moren);
        List<String> path = new ArrayList<>();
        if (!TextUtils.isEmpty(data.scene_pic)) {
            String[] split = data.scene_pic.split(",");
            for (int i = 0; i < split.length; i++) {
                path.add(ConStans.BaseUrl_Test_url + split[i]);
                //objects.add(R.mipmap.ic_launcher);
            }
        }

        //设置完成之前的图片
        //设置banner样式
        //mAllorderdetialBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
        //设置图片加载器
        mAllorderdetialBanner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        if (path.size() == 0) {
            mAllorderdetialBanner.setImages(objects);
        } else {
            mAllorderdetialBanner.setImages(path);
        }

        Log.e("pathsize", path.size() + "");
        //mAllorderdetialBanner.setImages(path);
        //设置banner动画效果
        mAllorderdetialBanner.setBannerAnimation(Transformer.DepthPage);
      /*  //设置标题集合（当banner样式有显示title时）
        mAllorderdetialBanner.setBannerTitles(titles);*/
        //设置自动轮播，默认为true
        mAllorderdetialBanner.isAutoPlay(true);
        //设置轮播时间
        mAllorderdetialBanner.setDelayTime(1500);
        //设置指示器位置（当banner模式中有指示器时）
        mAllorderdetialBanner.setIndicatorGravity(BannerConfig.CENTER);
        //banner设置方法全部调用完毕时最后调用
        mAllorderdetialBanner.start();

        //设置完成订单的图片
        if (mStatus == 6 || mStatus == 5) {
            mWanchengAll.setVisibility(View.VISIBLE);
            //TODO 设置完成时间和 完成之后拍的图片
            mTopLine.setVisibility(View.GONE);
            mWanchengTopAll.setVisibility(View.GONE);
            // mWanchengTopLeft.setText("抢单方");
            mWanchengAllLeft1.setText(data.finish_time + "");
            mWanchengAllLeft2.setText("完成图片");
            if (!TextUtils.isEmpty(data.work_end_pic)) {
                split = data.work_end_pic.split(",");
                mThreeImageAdapter.setSplit(split);
                mThreeImageAdapter.notifyDataSetChanged();
            }
       /* } else if (mStatus == 4 && data.account_id == Setting.getId()) {
            mWanchengAll.setVisibility(View.VISIBLE);
            //TODO 设置完成时间和 完成之后拍的图片
            mTopLine.setVisibility(View.VISIBLE);
            mWanchengTopAll.setVisibility(View.VISIBLE);
            mWanchengTopLeft.setText("抢单方");
            mWanchengAllLeft1.setText("公司介绍");
            mWanchengAllLeft2.setText("相关证件");*/
        } else {
            mWanchengAll.setVisibility(View.GONE);
            mTopLine.setVisibility(View.GONE);
            mWanchengTopAll.setVisibility(View.GONE);
            GetQiangDanInfo();
        }
        Log.e("status", data.status + "----" + mStatus);
        //根据订单状态设置按钮
        if (aBoolean) {
            switch (data.status) {
                case 0:
                    if (Setting.getId() == data.account_id) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("待抢单");
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("抢单");
                    }
                    break;

                case 1://待确认  身份  相同
                    if (Setting.getId() == data.account_id) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("确认完成");
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("等待发单方打款");
                    }

                    break;
                case 2://待施工
                    if (Setting.getId() == data.account_id) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("等待施工方开始施工");
                    } else if (Setting.getShenfen() == 3) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("开始施工");
                    } else if (Setting.getShenfen() == 4) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("开始施工");
                        mAllorderdetialRight.setText("导航");
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("开始施工");
                    }
                    break;
                case 3://已抢单
                    if (data.account_id == Setting.getId()) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.VISIBLE);
                        mAllorderdetialLeft.setText("取消订单");
                        mAllorderdetialRight.setText("确认施工");
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("待确认");
                    }
                    break;
                case 4://正在施工
                    if (data.account_id == Setting.getId()) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("等待施工完成");
                        /*mWanchengAll.setVisibility(View.VISIBLE);//显示公司信息*/
                    } else if (Setting.getShenfen() == 3) {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("完成订单");
                       /* mWanchengAll.setVisibility(View.GONE);*/
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("完成订单");
                        /*mWanchengAll.setVisibility(View.GONE);*/
                    }
                    break;
                case 5://施工完成
                    if (Setting.getId() == data.account_id) {
                        mAllButton.setVisibility(View.GONE);
                    } else {
                        mAllorderdetialLeft.setVisibility(View.VISIBLE);
                        mAllorderdetialRight.setVisibility(View.GONE);
                        mAllorderdetialLeft.setText("确认收款");
                    }

                    break;
                case 6://订单完成
                    mAllButton.setVisibility(View.GONE);
                    break;
                case 7://已取消
                    mAllorderdetialLeft.setVisibility(View.VISIBLE);
                    mAllorderdetialRight.setVisibility(View.GONE);
                    mAllorderdetialLeft.setText("删除");
                    break;
            }

        }


        //确认施工
        mAllorderdetialRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(is_pledge == 1){
                    String str = mAllorderdetialRight.getText().toString();
                    if (str.equals("确认施工")) {
                        QueRenShiGong(1);
                    } else if (str.equals("导航")) {
                        DaoHang();
                    }
                }else if(is_pledge == 2){
                    ShowToast.showToast(text);
                    startactivity(AllOrderDetialActivity.this, BaoZhenJinActivity.class);
                }else if(is_pledge == 3){
                    AlertDialog.Builder builder = new AlertDialog.Builder(AllOrderDetialActivity.this);
                    builder.setTitle("提示信息").setIcon(android.R.drawable.ic_dialog_alert);
                    builder.setMessage(text);
                    builder.create().show();//创建并展示对话框
                }

            }

        });

        mAllorderdetialLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(is_pledge == 1){
                    String text = mAllorderdetialLeft.getText().toString();
                    if (text.equals("确认完成")) {
                        if (mStatus == 4) {

                            FinishOrder(4);
                        } else {
                            QueRenFinish(1);
                        }
                    } else if (text.equals("取消订单")) {
                        QuxiaoOrder(6);
                    } else if (text.equals("开始施工")) {
                        StartShigong(3);
                    } else if (text.equals("待确认")) {
                        DaiQueRen();
                    } else if (text.equals("完成订单")) {
                        FinishOrder(4);
                    } else if (text.equals("确认收款")) {
                        QueRenMoney(7);
                    } else if (text.equals("删除")) {
                        DeleteOrder();
                    } else if (text.equals("抢单")) {
                        QiangDan(2);
                    } else if (text.equals("待抢单")) {
                        ShowToast.showToast("请耐心等待订单被抢");
                    }
                }else if(is_pledge == 2){
                    ShowToast.showToast("未交付押金");
                    startactivity(AllOrderDetialActivity.this, BaoZhenJinActivity.class);
                }else if(is_pledge == 3){
                    AlertDialog.Builder builder = new AlertDialog.Builder(AllOrderDetialActivity.this);
                    builder.setTitle("提示信息").setIcon(android.R.drawable.ic_dialog_alert);
                    builder.setMessage(text);
                    builder.create().show();//创建并展示对话框
                }

            }
        });


    }

    //确认施工
    private void QueRenShiGong(int i) {
        MyRequest request = new MyRequest(ConStans.OrderDetialButton_Url, RequestMethod.POST);
        request.add("type", i);
        request.add("id", mData.id);
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {

                StatusBean statusBean = GsonUtil.GsonToBean(json, StatusBean.class);
                if (statusBean != null) {
                    if (statusBean.status == 1) {
                        mMessageDialog.setMessage(statusBean.msg).setIcon(R.mipmap.tijiao).setTitle("确认成功").showit();
                    } else {
                        mMessageDialog.setMessage(statusBean.msg).setIcon(R.mipmap.quxiao).setTitle("确认失败").showit();
                    }
                }

            }
        });
    }

    //抢单
    private void QiangDan(int i) {
        Log.e("stat", i + "--" + mData.id + "---" + Setting.getId());
        MyRequest request = new MyRequest(ConStans.OrderDetialButton_Url, RequestMethod.POST);
        request.add("type", i);
        request.add("id", mData.id);
        request.add("userid", Setting.getId());
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                StatusBean statusBean = GsonUtil.GsonToBean(json, StatusBean.class);
                if (statusBean != null) {
                    ShowToast.showToast(statusBean.msg + "");

                    if (statusBean.status == 1) {
                        mMessageDialog.setTitle("抢单成功").setIcon(R.mipmap.tijiao).setMessage(statusBean.msg);
                        mMessageDialog.showit();
                    } else {
                        mMessageDialog.setTitle("抢单失败").setIcon(R.mipmap.quxiao).setMessage(statusBean.msg);
                        mMessageDialog.showit();
                    }
                }
            }
        });
    }

    //导航
    private void DaoHang() {
        startactivity(this, DaoHangActivity.class);
    }


    //删除
    private void DeleteOrder() {
        MyRequest request = new MyRequest(ConStans.DeleteOrder_Url);
        request.add("id", mId);
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                StatusBean statusBean = GsonUtil.GsonToBean(json, StatusBean.class);
                if (statusBean != null) {
                    ShowToast.showToast(statusBean.msg);
                    finish();
                }

            }
        });

    }

    //确认收款
    private void QueRenMoney(int i) {
        MyRequest request = new MyRequest(ConStans.OrderDetialButton_Url, RequestMethod.POST);
        request.add("id", mData.id);
        request.add("type", i);
        CallServer.getInstance().addPost(this, request, 1, new OnCallBack() {
            @Override
            public void OnSuccess(int what, String json, Object ject) {
                StatusBean statusBean = GsonUtil.GsonToBean(json, StatusBean.class);
                if (statusBean != null) {
                    if (statusBean.status == 1) {
                        mMessageDialog.setMessage(statusBean.msg).setIcon(R.mipmap.tijiao).setTitle("收款成功").showit();
                    } else {
                        mMessageDialog.setMessage(statusBean.msg).setIcon(R.mipmap.quxiao).setTitle("收款失败").showit();
                    }
                }
            }
        });
    }

    //完成订单
    private void FinishOrder(final int i) {
        Intent intent = new Intent(AllOrderDetialActivity.this, WanchengDingdanActivity.class);
        intent.putExtra("type", i);
        intent.putExtra("id", mData.id);
        intent.putExtra("scene_pic", mData.scene_pic);
        intent.putExtra("is_bills", mData.is_bills);
        startActivity(intent);
    }

    //待确认
    private void DaiQueRen() {
        ShowToast.showToast("请耐心等待发单方确认");
    }

    //开始施工
    private void StartShigong(int i) {


        Intent intent = new Intent(this, StartShigongActivity.class);
        intent.putExtra("type", i);
        intent.putExtra("id", mData.id);
        intent.putExtra("scene_pic", mData.scene_pic);
        intent.putExtra("is_bills", mData.is_bills);
        startActivity(intent);

    }

    //取消订单
    private void QuxiaoOrder(final int i) {

        mDismissDialog.setOk(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyRequest request = new MyRequest(ConStans.OrderDetialButton_Url, RequestMethod.POST);
                request.add("type", i);
                request.add("id", mData.id);
                request.add("remark", mDismissDialog.getBody());
                CallServer.getInstance().addPost(AllOrderDetialActivity.this, request, 1, new OnCallBack() {
                    @Override
                    public void OnSuccess(int what, String json, Object ject) {
                        mMessageDialog.showit();

                    }
                });
            }
        }).setdismiss(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDismissDialog.dismiss();
            }
        }).show();


    }

    //确认完成
    private void QueRenFinish(int i) {

        //startactivity(this, FinishShigongActivity.class);


        Intent intent = new Intent(this, FinishShigongActivity.class);
        intent.putExtra("type", i);
        intent.putExtra("id", mData.id);
        intent.putExtra("work_end_pic", mData.work_end_pic);
        intent.putExtra("order_no",mData.order_no);
        intent.putExtra("price",mData.price);
        //intent.putExtra("is_bills", mData.is_bills);
        Log.e("价格",mData.price + "--");
        startActivity(intent);


    }


}
